from django.contrib import admin

from .models import Town, Village, Deadman, Manager

class VillageInline(admin.StackedInline):
    model = Village
    extra = 1

class TownAdmin(admin.ModelAdmin):
    list_display = ('name',)
    search_fields = ['name',]
    ordering = ('name',)
    inlines = [VillageInline]

class VillageAdmin(admin.ModelAdmin):
    list_display = ('name',)
    search_fields = ['name',]
    ordering = ('name',)

class DeadmanAdmin(admin.ModelAdmin):
    list_display = ('deadman_name', 'village', 'kin_name', 'phone', 'dead_date')
    search_fields = ['deadman_name', 'kin_name', 'phone']
    ordering = ('dead_date', 'deadman_name',)

admin.site.register(Manager)
admin.site.register(Town)
admin.site.register(Village, VillageAdmin)
admin.site.register(Deadman, DeadmanAdmin)

